/*
 * =====================================================================================
 *
 *       Filename:  Decorator.cpp
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  2015年01月23日 15时13分49秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  LiuYi (), swliuyi@gmail.com
 *   Organization:  
 *
 * =====================================================================================
 */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <limits.h>
#include <iostream>
#include <memory>

using namespace std;

class People
{
    private:
        string name;
    public:
        People(string n=""):name(n){}
        virtual void show()
        {
            cout<<"装扮的"<<name<<endl;
        }
};

class Finery: public People
{
    protected:
        shared_ptr<People> component;
    public:
        void Decorate(shared_ptr<People> c)
        {
            component = c;
        }
        virtual void show()
        {
            component->show();
        }
};

class TShirts : public Finery
{
    public:
        virtual void show()
        {
            cout<<"T-shrit"<<endl;
            Finery::show(); 
        }
};

class BigTrouser : public Finery
{
    public:
        virtual void show()
        {
            cout<<"BigTrouser"<<endl;
            Finery::show(); 
        }
};

int main(int argc, char *argv[])
{
    shared_ptr<People> ly(new People("ly"));
    shared_ptr<TShirts> ts(new TShirts);
    shared_ptr<BigTrouser> bt(new BigTrouser);

    ts->Decorate(ly);
    bt->Decorate(ts);
    bt->show();

    bt->Decorate(ly);
    ts->Decorate(bt);
    ts->show();
}
